package com.tpsix.datascope;

import com.tpsix.controller.vm.RoleVM;
import com.tpsix.enums.DataScopeTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class DataScopeContext {

    @Autowired
    private final Map<String, DataScopeHandler> dataScopeHandlerMap = new HashMap<>();

    public List<Integer> getDeptIds(RoleVM roleVM, Integer type) {
        DataScopeTypeEnum dataScopeTypeEnum = DataScopeTypeEnum.of(type);
        String handler = dataScopeTypeEnum.getHandler();
        return dataScopeHandlerMap.get(handler).getDeptIds(roleVM, dataScopeTypeEnum);
    }

}
